#!/bin/bash
start_time=$(date +%s)

# 0 5
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
sudo ./scripts/load_one.sh 111969901601639.csv
wait
echo load完成

sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
sudo ./scripts/run_lsm_one.sh 111969901601639.csv
wait
echo run_lsm完成

sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
sudo ./scripts/load_one.sh 111969901601639.csv
wait
echo load完成

sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
sudo ./scripts/run_baseline_one.sh 111969901601639.csv
wait
echo run_baseline完成

# 下面的是统计性能，fork自all_trace.sh
path=../data/ebs_segment_io_records/AY283G_2022-01-01_00:00:00_2022-01-02_00:00:00/device/
for filename in 111969901601639.csv; do
  data_path=${path}${filename}
  data_name=${filename%.*}
  for executable_file in trace_allGet trace_realRun ; do
    python ./scripts/collect_results.py 1 ${data_name}_${executable_file}_16 > ../evaluation/expr_${data_name}_${executable_file}_16.txt &
  done
  wait

  for executable_file in trace_allGet trace_realRun ; do
    cat ../evaluation/expr_${data_name}_${executable_file}_16.txt
  done

  # plot iteration decay
  python ./scripts/plot2_iterationDecay.py ${data_name}
done

# 整体的plot
#python ./scripts/plot3_mean_and_speedUp.py 0 5

# 结束，统计时间
end_time=$(date +%s)
cost_time=$((end_time-start_time))
echo "$0" "运行时间：$((cost_time/60))min $((cost_time%60))s"
newpath=../evaluation_global_pair1639_0_5tr/
if [ ! -d ${newpath} ]; then
  mkdir ../evaluation_global_pair1639_0_5tr/
fi
cp ../evaluation_analyse/num_ops_period.txt ../evaluation_global/
mv ../evaluation_global/* ../evaluation_global_pair1639_0_5tr/
